<!--  -->
<template>
  <div>

现病史 {{ formData.name }}



<el-checkbox-group @change="handleChange" v-model="checkList">
    <el-checkbox v-for="item in state.list" :key="item.id" :label="item.name" :value="item.name" />
    
  </el-checkbox-group>

  </div>
</template>

<script lang='ts' setup>
import { reactive,toRefs,ref,onMounted, inject, watchEffect} from 'vue'

import { getDiseaseList } from '../../apis/disease/disease';
import { DiseaseList } from '../../apis/disease/type';
import { Elderly } from '../../apis/elderly/type';


const formData= inject<Elderly>("formData")!
const checkList = ref<string[]>([])
 watchEffect(()=>{
    checkList.value = formData.health?.nowillness.split(",") || [];
 })



const state = reactive<DiseaseList>({
    list:[],
})
const getData=async ()=>{
  const res=await  getDiseaseList();
  state.list=res.list;
}

const handleChange=(val:string[])=>{
   
    console.log(1111111111,val);
   
        formData.health!.nowillness=val.join();
     


    
}

getData();
</script>
<style scoped>
</style>